<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>分成资金 - 添加</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-form.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/YWLib.js"></script>
    <style type="text/css">
        .table {
            border: 1px solid #FFE7BA;
        }
        .table tr {
            border: 1px solid #FFE7BA;
        }
        .table tr td {
            border: 1px solid #FFE7BA;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            selectXzqh("xzqh");
            selectXmnf("xmnf");
        });

        function selectXmnf(id) {
            $("#" + id).combobox({
                valueField:'value',
                textField: 'text',
                data: [{
                    value: "2022",
                    text: "2022"
                },{
                    value: "2023",
                    text: "2023"
                },{
                    value: "2024",
                    text: "2024"
                },{
                    value: "2025",
                    text: "2025"
                },{
                    value: "2026",
                    text: "2026"
                }]
            });
            $("#" + id).combobox("setValue", new Date().getFullYear());
        }

        function selectXzqh(id) {
            $("#" + id).combobox({
                valueField:'id',
                textField: 'name',
                data: [{
                    id: '360100',
                    name: '南昌市'
                },{
                    id: '360200',
                    name: '景德镇市'
                },{
                    id: '360300',
                    name: '萍乡市'
                },{
                    id: '360400',
                    name: '九江市'
                },{
                    id: '360500',
                    name: '新余市'
                },{
                    id: '360600',
                    name: '鹰潭市'
                },{
                    id: '360700',
                    name: '赣州市'
                },{
                    id: '360800',
                    name: '吉安市'
                },{
                    id: '360900',
                    name: '宜春市'
                },{
                    id: '361000',
                    name: '抚州市'
                },{
                    id: '361100',
                    name: '上饶市'
                }]
            });
        }

        function yzszNew(id) {
            if(isNaN(Number($(id).val()))) {
                alert('请填入数字！');
                $(id).val('');
                $(id).focus();
            }
        }

        function closeWindow() {
            parent.$('#mywin').window('destroy');
        }

        function sumDfzc() {
            $('#dfzc').val(parseFloat($('#dszc').val() === "" ?0:$('#dszc').val())
                +parseFloat($('#qxzc').val() === "" ?0:$('#qxzc').val())
                +parseFloat($('#qtzc').val() === "" ?0:$('#qtzc').val()) );
        }

        function zjJhsharetj() {
            if ($("#xzqh").combobox("getValue") == "" ||
                $("#xzqh").combobox("getValue") == null) {
                alert('请选择行政区划！');
                return;
            }

            if ($("#jhxdwh").val() == '' || $("#jhxdwh").val() == null) {
                alert('请输入计划下达文号！');
                return;
            }

            var cgs = $("#cgs").val() == "" || $("#cgs").val() == null ? 0 : parseFloat($("#cgs").val());
            var stz = $("#stz").val() == "" || $("#stz").val() == null ? 0 : parseFloat($("#stz").val());
            var ttc = $("#ttc").val() == "" || $("#ttc").val() == null ? 0 : parseFloat($("#ttc").val());
            var dfzc = $("#dfzc").val() == "" || $("#dfzc").val() == null ? 0 : parseFloat($("#dfzc").val());

            var ztz = cgs + stz + ttc + dfzc;

            if (ztz <= 0) {
                alert('请填写正确的资金！');
                return;
            }

            var params = {
                'xzqhdm': $("#xzqh").combobox("getValue"),
                'xzqh': $("#xzqh").combobox("getText"),
                'xmnf': $("#xmnf").combobox("getValue"),
                'cgs': cgs,
                'stz': stz,
                'ttc': ttc,
                'dfzc': dfzc,
                'ztz': ztz,
                'jhxdwh': $("#jhxdwh").val()
            };

            loadjzt();
            $.ajax({
                type: 'post',
                url: '/jxcsxm/shares/addSharefundData.do',
                data: params,
                dataType: 'json',
                success: function (data) {
                    disLoadjzt();
                    alert(data.msg);
                    parent.$("#grid").datagrid("reload");
                    parent.loadTj();
                    parent.loadShareJhxdwh("jhxdwh", "share_funds");
                    closeWindow();
                }
            });
        }
    </script>
</head>
<body>
        <table class='table' style="width: 100%; background-color: #FFE7BA; font-size: 12px"
               border="0" cellpadding="3" cellspacing="1">
            <tr style="height: 35px;">
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    行政区划：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="text" name="xzqh" id="xzqh" style="width: 120px" />
                </td>
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    项目年份：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="text" name="xmnf" id="xmnf" style="width: 120px" />
                </td>
            </tr>
            <tr style="height: 35px;">
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    计划下达文号：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="text" name="jhxdwh" id="jhxdwh" style="width: 120px" />
                </td>
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    车购税：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="cgs" id="cgs" onchange="yzszNew(this)" style="width: 120px" />万元</td>
            </tr>
            <tr style="height: 35px;">
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    省投资：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="stz" id="stz" onchange="yzszNew(this)" style="width: 120px" />万元</td>
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    地方自筹：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="dfzc" id="dfzc" readonly style="width: 120px" />万元</td>
            </tr>
            <tr style="height: 35px;">
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    厅统筹：
                </td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="ttc" id="ttc" onchange="yzszNew(this)" style="width: 120px" />万元
                </td>
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    地市财政自筹：
                </td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="dszc" id="dszc" onchange="yzszNew(this)" style="width: 120px"  oninput="sumDfzc()"/>万元
                </td>
            </tr>
            <tr style="height: 35px;">
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    区县财政自筹：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="qxzc" id="qxzc" onchange="yzszNew(this)" style="width: 120px" oninput="sumDfzc()"/>万元
                </td>
                <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
                    其他自筹：</td>
                <td style="background-color: #ffffff; height: 20px;" align="left">
                    <input type="number" name="qtzc" id="qtzc" onchange="yzszNew(this)" style="width: 120px" oninput="sumDfzc()"/>万元
                </td>
            </tr>
            <tr style="height: 35px;">
                <td colspan="4" style="background-color: #ffffff;"align="center">
                    <a id='mybuttion1' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:zjJhsharetj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">保存</a>
                    <a id='mybuttion2' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:closeWindow()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">取消</a>
            </tr>
        </table>
</body>
</html>
